#include("/WEB-INF/admin/common/header.html")


<body class="childrenBody">
	<form class="layui-form layui-form-search">
		<div class="layui-inline">
		    <div class="layui-input-inline">
            <label>菜单名称：</label>
           
		    </div>
		    <div class="layui-input-inline">
		     <input type="text"  class="layui-input " name="menuname">
		    </div>
		    <button class="layui-btn layui-search" lay-submit lay-filter="menusearch"><i class="layui-icon">&#xe615;</i>查询</button>		   
		     <a #shiroHasPermission('security:generator:add') class="layui-btn layui-add" ><i class="layui-icon"></i>添加</a>	
		</div>
	</form>	
	<div class="layui-form  data-table-Wrapper">
		<a  onclick="tableReload()"></a>
		<table  id="menu" lay-filter="menu"></table>		
		<script type="text/html" id="operation">
			<div class="operation">
				<a #shiroHasPermission('security:generator:edit') class="export" href="javascript:;"  lay-event="export"> 导出</a>
                
			</div>
		</script>
	</div>
	
	<script type="text/javascript" src="#(BASE_PATH)/static/layui/layui.js"></script>
	<script>
	var tableIns;
	layui.use(['table','laydate','form','jquery'],function(){
		var table = layui.table,
		 	form = layui.form,
		 	$ = layui.jquery;
		
		
		tableIns = table.render({
		        elem: '#menu',
		        height: 'full-90', //容器高度
		        url: '#(BASE_PATH)/security/generator/pageJson',
		        page: false,
		        limit:19,
		        cellMinWidth: 80,
		        id: 'menu',
		        cols: [[
		                {field: 'tableName', title: 'tableName',unresize:true},
		                {field: 'engine', title: 'engine',unresize:true},
		                {field: 'tableComment', title: 'tableComment',unresize:true},
		                {field: 'createTime', title: 'createTime',unresize:true},
		                {title: '操作', toolbar: '#operation',width:162,unresize:true},
		                ]],  
		               done: function(res, curr, count) {
		               },
		        loading: true
		    });
		 
		  //查询
		  form.on('submit(menusearch)', function(data) {
			  console.log(data)
		        tableIns.reload({
		            where: data.field
		        });		       
		        return false; 
		    });
	
		  
		   //添加
		  $(".layui-add").click(function(){
			  layer.load();
              layer.open({
                  title: "添加菜单",
                  type: 2,
                  shade: 0.4,
                  content: '#(BASE_PATH)/security/menu/add',
                  area: ['520px', '550px'],
                  shadeClose: true,   
                  cancel :function(){
                  },
                  success: function(layero, index){
                	  layer.closeAll('loading');
                  }
              	});             				
			 })  
			 
	 //监听工具条
		  table.on('tool(menu)', function(obj){
		    var data = obj.data;
		    var id=data.id;
		    var tableName = data.tableName;
		    if(obj.event === 'export'){ 
	              
			    	layer.confirm('确认要开启该用户吗？', {
			            btn : [ '确定', '取消' ]
			        }, function(index) {
			        	$.ajax({
			        		 type:'get',	
			        		 url:'#(BASE_PATH)/security/generator/export?tableName='+tableName,       		  		       		  		       		 
				       		 success:function(msg){
				       			obj.del();	
				       			layer.msg("代码存放在D:/generatoe", {time: 1000});
				       			tableIns.reload();
				       		 }
			       	  }) 
			        });
	  			
		    }
		 })
		 
	})
	function tableReload(){
			tableIns.reload({});	
		}
	</script>
</body>
</html>
